var nozzle_size_p = 0.4																				;nozzle size of primary print head
var nozzle_size_s = 0.4																				;nozzle size of secondary print head
var accuracy = 0.1																					;accuracy for each pattern

var x_position = 150																				;start position in X axis
var y_position= 150																					;start position in Y axis
var y_move = 30																						;size of the patern on Y axis
var x_move = 10																						;size of the patern on X axis
var z_p= var.nozzle_size_p / 2																		;start position in Z axis for primary print head
var z_s= var.nozzle_size_s / 2																		;start position in Z axis for secondary print head
var e_p = var.nozzle_size_p * var.nozzle_size_p * 0.358												;amount of extrude in relation to length for primary print head
var e_s = var.nozzle_size_s * var.nozzle_size_s * 0.358												;amount of extrude in relation to length for secondary print head
var x_accuracy=var.accuracy*20/2																	;start position of the accuracy in X axis
var loops = 40;


M107
G28																									;home all axes
G29 S1
G1 Z5 F5000																							;lift nozzle
M291 S3 R"Verify filament is loaded, bed is heated" P"Press OK to continue, or CANCEL to abort"
echo "Verify nozzle size and temperature","T0", var.nozzle_size_p,"T1", var.nozzle_size_s, "accuracy",var.accuracy,
G4 S1
M104 S200 T0																						;set temperature primary
M104 S200 T1																						;set temperature secondary
M109 S200 T0																						;set temperature primary and wait for it to be reached
M109 S200 T1																						;set temperature secondary and wait for it to be reached
M106 P0 S0
M106 P1 S0
G4 S3

T0
G1 E10
M83																									;use relative distances for extrusion
G1 Z3
G90																									;use absolute coordinates
G1 X{var.x_position-100} Y{var.y_position} F3000
G1 Z{var.z_p} F1000
G1 X{var.x_position} Y{var.y_position} E{var.e_p*100*2} F1000										;start T0 straight line for cleaning the nozzle
G91																									;use relative positioning for the XYZ axes
G1 Y{-var.y_move} E{var.e_p*var.y_move} F1000
G1 X{var.x_move} E{var.e_p*var.x_move} F1000

while true																							;start T0 pattern
	if iterations < var.loops/2-2;
		G1 X{var.x_move/2} Y{var.y_move} E{var.e_p*var.y_move} F2000
		G1 X{var.x_move/2} Y{-var.y_move} E{var.e_p*var.y_move} F2000
		G1 X{var.x_move} E{var.e_p*var.x_move} F1000
	
	if iterations = var.loops/2-2																	;close T0 pattern
		G1 Y{var.y_move} E{var.e_p*var.y_move} F2000
		G90																							;use absolute coordinates
		G28 Y																						;home all axes

	if iterations = var.loops/2-1																	;start T1 straight line for cleaning the nozzle
		T1
		G1 E10
		G1 Z3 F2000
		G1 X{var.x_position-100} Y{var.y_position + var.nozzle_size_s+var.nozzle_size_p+2*var.y_move} F10000
		G1 Z{var.z_s} F1000
		G1 X{var.x_position - var.x_accuracy} Y{var.y_position + var.nozzle_size_s+var.nozzle_size_p+2} E{var.e_s*100*2} F3000 ;start T1 pattern from offset of -2 (X-2)
		G1 X{var.x_position-var.x_accuracy} Y{var.y_position+var.y_move+ var.nozzle_size_s+var.nozzle_size_p} E{var.e_s*var.y_move} F2000
		G1 X{var.x_position-var.x_accuracy+var.x_move} Y{var.y_position+var.y_move+ var.nozzle_size_s+var.nozzle_size_p} E{var.e_s*var.x_move} F2000
		G91																							;use relative positioning for the XYZ axes

	if iterations > var.loops/2-1 & iterations < var.loops*3/4-1									;T1 pattern from offset of -2 to offset 0
		G1 X{var.accuracy} E{var.e_s*var.accuracy} F500
		G1 X{var.x_move/2} Y{-var.y_move} E{var.e_s*var.y_move} F1000
		G1 X{var.x_move/2} Y{var.y_move} E{var.e_s*var.y_move} F1000
		G1 X{var.x_move} E{var.e_s*var.x_move} F1000

	if iterations > var.loops*3/4-1.5 & iterations < var.loops*3/4-0.5								;T1 pattern of offset 0	(X=X)
		G1 X{var.accuracy} E{var.e_s*var.accuracy} F500
		G1 X{var.x_move/2} Y{-var.y_move} E{var.e_s*var.y_move} F1000
		G1 X{var.x_move/2} Y{var.y_move} E{var.e_s*var.y_move} F1000
		G1 X{-var.x_move/2} Y{var.y_move} E{var.e_s*var.y_move} F1000
		G1 X{-var.x_move/2} Y{-var.y_move} E{var.e_s*var.y_move} F1000
		G1 X{var.x_move*2} E{var.e_s*var.x_move*2} F500

	if iterations > var.loops*3/4-0.5 & iterations < var.loops-2									;T1 pattern from offset of 0 to offset 2	
		G1 X{var.accuracy} E{var.e_s*var.accuracy} F500
		G1 X{var.x_move/2} Y{-var.y_move} E{var.e_s*var.y_move} F1000
		G1 X{var.x_move/2} Y{var.y_move} E{var.e_s*var.y_move} F1000
		G1 X{var.x_move} E{var.e_s*var.x_move} F1000

	if iterations = var.loops-2																		;T1 pattern of offset +2 (X=X+2)
		G1 X{var.accuracy} E{var.e_s*var.accuracy} F500
		G1 Y{-var.y_move} E{var.e_s*var.y_move} F2000		
		break
	
G90																									;use absolute coordinates
G28																									;home all axes

M291 S3 R"Go to cofig_probe_X" P"Left = +X, Right = -X"